package xufei.user.controller;

import com.xufei.common.domain.common.AjaxJson;
import com.xufei.common.domain.user.User;
import org.springframework.web.bind.annotation.*;
import xufei.user.service.UserService;
import java.util.List;

@RestController
@RequestMapping("user")
public class UserController {

    private final UserService userService;

    public UserController(UserService userService) {
        this.userService = userService;
    }

    @RequestMapping("list")
    public AjaxJson list(User user){
        List<User> sysUsers = userService.selectUserList(user);
        return AjaxJson.data(sysUsers);
    }

    @RequestMapping("updateIntegral")
    public AjaxJson updateIntegral(@RequestBody User user){
        userService.updateIntegral(user);
        return AjaxJson.ok();
    }

    @RequestMapping("selectUserByUsername")
    public User selectUserByUsername(String userName){
        User user = userService.selectUserByUsername(userName);
        return user;
    }



}
